Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

fix(typeahead): run validators manually on select #3352

Closed
wants to merge 1 commit into from

Conversation

sagens42
Copy link

@sagens42 sagens42 commented Mar 2, 2015

fix for #3311

@@ -251,6 +251,11 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap
$setModelValue(originalScope, model);
modelCtrl.$setValidity('editable', true);

if (modelCtrl.$$lastCommittedViewValue === modelCtrl.$viewValue) {
// angular will check if model value changed to run validators, so we need to run it manually
modelCtrl.$$runValidators(undefined, modelCtrl.$modelValue, modelCtrl.$viewValue, angular.noop);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are undocumented API. Is there any way to this with the documented API (prefixed with a single $)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think it's enough to run $setValidity for parse key

var match = $(findMatches(element)[0]).find('a')[0];
$(match).click();

expect($scope.form.input.$error.parse).toBeUndefined();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add a check for the $error before the click as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parsed error was introduced in 1.3, so it's impossible to test it in current environment ( angular 1.2.16 )

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sagens42 we've updated the project to AngularJS 1.3 recently

@sagens42
Copy link
Author

sagens42 commented Apr 6, 2015

Fixed in #3166 Closing

@katerberg
Copy link

It looks like this is still an issue with the new $validators. If I have a custom validator added and I type the exact item in a list, it does not fire that validator again after selecting an item. Should I create a new issue for this?

@icfantv
Copy link
Contributor

icfantv commented Dec 29, 2015

@katerberg - yes, please. Here are the instructions for doing so, thanks.

@katerberg
Copy link

@icfantv Created #5136. Let me know if I am missing something since this is my first time contributing a bug to this. Thanks for pointing me in the right direction!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants